#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <unistd.h>
#include <errno.h>

#include <bcmnvram.h>

#include "librc.h"

int nvram_get_int(const char *key)
{
	return atoi(nvram_safe_get(key));
}

int nvram_set_int(const char *key, int value)
{
	char nvramstr[16];

	snprintf(nvramstr, sizeof(nvramstr), "%d", value);
	return nvram_set(key, nvramstr);
}

char *nvram_prefix_get(const char *prefix, const char *name)
{
	char tmp[strlen(prefix) + strlen(name) + 1];
	strcpy(tmp, prefix);
	strcat(tmp, name);
	return nvram_safe_get(tmp);
}